Context.Response.GetCookie Method

Syntax

Context.Response.GetCookie as A (CookieName as C)

Arguments

CookieNameCharacter

The name of the cookie to fetch.

Returns

cookieSystem::Web::HttpCookieZ

Returns a cookie as an System::Web::HttpCookie object if the cookie exists. If no cookie exists, returns a null value.

Description

Returns a cookie if the cookie exists.

Discussion

Context.Response.GetCookie returns a System::Web::HttpCookie object if the cookie exists. If the cookie does not exist, Context.Response.GetCookie returns a null value.

dim cookieName as c = "myCookie"

cookie = Context.Response.GetCookie(cookieName)

'test the cookie for a null value.
if (cookie == null_value()) then
    ? "Cookie does not exist!"
else 
    ? cookie.Name + " has a value of " + cookie.Value
end if

In addition to using the null_value() method, you can alternatively compare the type of the variable returned by Context.Response.GetCookie to "Z", the null data type:

if (typeof(cookie) == "Z") then
? "Cookie does not exist!"
end if

See Also